#$Id: quicksort.py 6 2008-11-24 15:21:18Z Eric.Nevup $

def quick_sort(seq, start, end):
    if (start >= end):
        print('start = ', start, ' |end = ', end)
        return
    v = partition(seq, start, end)
    quick_sort(seq, start, v - 1)
    quick_sort(seq, v + 1, end)

def partition(seq, i_st, i_ed):
    edge = i_st - 1
    for i in range(i_st, i_ed):
        if (seq[i] > seq[i_ed]):
            edge = edge + 1
            seq[edge], seq[i] = (seq[i], seq[edge])      
    seq[i_ed], seq[edge+1] = (seq[edge+1], seq[i_ed])
    return edge+1


seq = [2,8,7,1,3,5,6,4,5,5,8,8,3,3,8,8]
seq1 = [8]
print(quick_sort(seq,0,len(seq)-1))
print(seq)

    
